//
//  Open_MainViewController.m
//  OpenYooxi_IOS
//
//  Created by YeahYes on 15/3/16.
//  Copyright (c) 2015年 com.ivyvi.ee. All rights reserved.
//

#import "Open_MainViewController.h"
#import "MainSouSuoTableViewCell.h"
#import "YuanJiaoButtonTableViewCell.h"
#import "FourShoppingTableViewCell.h"
#import "ShoppingXiangQingTableViewCell.h"

static NSString *identifys = @"Cells";
static NSString *identify = @"Cell";
static NSString *identify1 = @"Cell1";
static NSString *identify2 = @"Cell2";

@interface Open_MainViewController (){
    NSArray *arrayshu;
}

@end

@implementation Open_MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    arrayshu = @[@"2",@"2",@"2",@"2",@"2",@"2",@"2"];
    //圆角的设置
    _yuanjiaoViews.layer.cornerRadius = 4;
    _yuanjiaoViews.layer.masksToBounds = YES;
    
    _Maintableview.dataSource = self;
    _Maintableview.delegate = self;
    //    _ShouChangTableview.pagingEnabled = YES;
    _Maintableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    //取消tableview右侧的滑动条
    _Maintableview.showsVerticalScrollIndicator = NO;
    _Maintableview.backgroundColor = UIColorFromRGB(0xF7F7F7);

    UINib *nib = [UINib nibWithNibName:@"MainSouSuoTableViewCell" bundle:[NSBundle mainBundle]];
    [_Maintableview registerNib:nib forCellReuseIdentifier:identify];
    
    
    UINib *nib1 = [UINib nibWithNibName:@"YuanJiaoButtonTableViewCell" bundle:[NSBundle mainBundle]];
    [_Maintableview registerNib:nib1 forCellReuseIdentifier:identifys];
    
    
    UINib *nib2 = [UINib nibWithNibName:@"FourShoppingTableViewCell" bundle:[NSBundle mainBundle]];
    [_Maintableview registerNib:nib2 forCellReuseIdentifier:identify1];
    
    UINib *nib3 = [UINib nibWithNibName:@"ShoppingXiangQingTableViewCell" bundle:[NSBundle mainBundle]];
    [_Maintableview registerNib:nib3 forCellReuseIdentifier:identify2];
}

#pragma mark - UITableView delegate 设置单元格高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(indexPath.row==0){
        return 172;
    }else if (indexPath.row==1){
    return 179;
    }else if(indexPath.row==2){
        return 320;

    }else{
        if(arrayshu.count<=4){
            return 136;
        }
        return 250;
    }
    return 0;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if(indexPath.row == 0){
        MainSouSuoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone; //取消单元格的选中
        return cell;
    }else if (indexPath.row == 1){
        YuanJiaoButtonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifys forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone; //取消单元格的选中
        return cell;
    }else if (indexPath.row ==2){
        FourShoppingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify1 forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone; //取消单元格的选中
        return cell;
    }else{
        ShoppingXiangQingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify2 forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone; //取消单元格的选中
        if(arrayshu.count !=0){
            cell.tuandata = arrayshu;
        }

        
        return cell;
    
    }
    
    return nil;
}



//#pragma mark - 取消掉UITableView的选中状态
//
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    ShouChangNeiBu_ViewController *shouchangneibu = [[ShouChangNeiBu_ViewController alloc] initWithNibName:@"ShouChangNeiBu_ViewController" bundle:nil];
//    
//    
//    [self.navigationController pushViewController:shouchangneibu animated:YES];
//    [tableView deselectRowAtIndexPath:indexPath animated:NO];
//    
//}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
